<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>module RBS::Prototype::Helpers - rbs: Ruby Standard Library Documentation</title>


<script src="../../js/navigation.js" defer></script>
<script src="../../js/search.js" defer></script>
<script src="../../js/search_index.js" defer></script>
<script src="../../js/searcher.js" defer></script>
<script src="../../js/darkfish.js" defer></script>

<script src="../../js/jquery-3.2.0.min.js"></script>

<script src="../../js/vue.min.js"></script>
<script src="../../js/js.cookie.min.js"></script>

<link href="../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../css/rdoc.css" rel="stylesheet">
<link href="../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
  var index_rel_prefix = "../../";
  var darkModeCsseHref = "../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="module">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-i-any_node-3F">#any_node?</a>
    <li ><a href="#method-i-args_from_node">#args_from_node</a>
    <li ><a href="#method-i-block_from_body">#block_from_body</a>
    <li ><a href="#method-i-each_child">#each_child</a>
    <li ><a href="#method-i-each_node">#each_node</a>
    <li ><a href="#method-i-keyword_hash-3F">#keyword_hash?</a>
    <li ><a href="#method-i-untyped">#untyped</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="module-RBS::Prototype::Helpers">
    <h1 id="module-RBS::Prototype::Helpers" class="module">
      module RBS::Prototype::Helpers
    </h1>

    <section class="description">
    
    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-any_node-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">any_node?</span><span
                                class="method-args">(node, nodes: []) { |node| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="any_node-3F-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/prototype/helpers.rb, line 97</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">any_node?</span>(<span class="ruby-identifier">node</span>, <span class="ruby-value">nodes:</span> [], <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">node</span>)
    <span class="ruby-identifier">nodes</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">node</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">each_child</span> <span class="ruby-identifier">node</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">any_node?</span> <span class="ruby-identifier">child</span>, <span class="ruby-value">nodes:</span> <span class="ruby-identifier">nodes</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">nodes</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">nodes</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-args_from_node" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">args_from_node</span><span
                                class="method-args">(args_node)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>NOTE: args_node may be a nil by a bug</p>

<pre class="ruby"><span class="ruby-identifier">https</span><span class="ruby-value">:/</span><span class="ruby-operator">/</span><span class="ruby-identifier">bugs</span>.<span class="ruby-identifier">ruby</span><span class="ruby-operator">-</span><span class="ruby-identifier">lang</span>.<span class="ruby-identifier">org</span><span class="ruby-operator">/</span><span class="ruby-identifier">issues</span><span class="ruby-operator">/</span><span class="ruby-value">17495</span>
</pre>

                              <div class="method-source-code" id="args_from_node-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/prototype/helpers.rb, line 121</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">args_from_node</span>(<span class="ruby-identifier">args_node</span>)
  <span class="ruby-identifier">args_node</span>&amp;.<span class="ruby-identifier">children</span> <span class="ruby-operator">||</span> [<span class="ruby-value">0</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-value">0</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-block_from_body" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">block_from_body</span><span
                                class="method-args">(node)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="block_from_body-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/prototype/helpers.rb, line 8</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">block_from_body</span>(<span class="ruby-identifier">node</span>)
  <span class="ruby-identifier">_</span>, <span class="ruby-identifier">args_node</span>, <span class="ruby-identifier">body_node</span> = <span class="ruby-identifier">node</span>.<span class="ruby-identifier">children</span>
  <span class="ruby-identifier">_pre_num</span>, <span class="ruby-identifier">_pre_init</span>, <span class="ruby-identifier">_opt</span>, <span class="ruby-identifier">_first_post</span>, <span class="ruby-identifier">_post_num</span>, <span class="ruby-identifier">_post_init</span>, <span class="ruby-identifier">_rest</span>, <span class="ruby-identifier">_kw</span>, <span class="ruby-identifier">_kwrest</span>, <span class="ruby-identifier">block_var</span> = <span class="ruby-identifier">args_from_node</span>(<span class="ruby-identifier">args_node</span>)

  <span class="ruby-comment"># @type var body_node: node?</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">body_node</span>
    <span class="ruby-identifier">yields</span> = <span class="ruby-identifier">any_node?</span>(<span class="ruby-identifier">body_node</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:YIELD</span> }
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">yields</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">block_var</span>
    <span class="ruby-identifier">required</span> = <span class="ruby-keyword">true</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">body_node</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">any_node?</span>(<span class="ruby-identifier">body_node</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:FCALL</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">children</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value">:block_given?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">n</span>.<span class="ruby-identifier">children</span>[<span class="ruby-value">1</span>] }
        <span class="ruby-identifier">required</span> = <span class="ruby-keyword">false</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">_rest</span> <span class="ruby-operator">==</span> <span class="ruby-value">:*</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">block_var</span> <span class="ruby-operator">==</span> <span class="ruby-value">:&amp;</span>
      <span class="ruby-comment"># ... is given</span>
      <span class="ruby-identifier">required</span> = <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_var</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">body_node</span>
        <span class="ruby-identifier">usage</span> = <span class="ruby-constant">NodeUsage</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">body_node</span>)
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">usage</span>.<span class="ruby-identifier">each_conditional_node</span>.<span class="ruby-identifier">any?</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:LVAR</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">children</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">block_var</span> }
          <span class="ruby-identifier">required</span> = <span class="ruby-keyword">false</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">method_block</span> = <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Block</span>.<span class="ruby-identifier">new</span>(
      <span class="ruby-value">required:</span> <span class="ruby-identifier">required</span>,
      <span class="ruby-value">type:</span> <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Function</span>.<span class="ruby-identifier">empty</span>(<span class="ruby-identifier">untyped</span>),
      <span class="ruby-value">self_type:</span> <span class="ruby-keyword">nil</span>
    )

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">yields</span>
      <span class="ruby-identifier">yields</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">yield_node</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">array_content</span> = <span class="ruby-identifier">yield_node</span>.<span class="ruby-identifier">children</span>[<span class="ruby-value">0</span>]&amp;.<span class="ruby-identifier">children</span>&amp;.<span class="ruby-identifier">compact</span> <span class="ruby-operator">||</span> []

        <span class="ruby-comment"># @type var keywords: node?</span>
        <span class="ruby-identifier">positionals</span>, <span class="ruby-identifier">keywords</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">keyword_hash?</span>(<span class="ruby-identifier">array_content</span>.<span class="ruby-identifier">last</span>)
                                  [<span class="ruby-identifier">array_content</span>.<span class="ruby-identifier">take</span>(<span class="ruby-identifier">array_content</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>), <span class="ruby-identifier">array_content</span>.<span class="ruby-identifier">last</span>]
                                <span class="ruby-keyword">else</span>
                                  [<span class="ruby-identifier">array_content</span>, <span class="ruby-keyword">nil</span>]
                                <span class="ruby-keyword">end</span>

        <span class="ruby-keyword">if</span> (<span class="ruby-identifier">diff</span> = <span class="ruby-identifier">positionals</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">method_block</span>.<span class="ruby-identifier">type</span>.<span class="ruby-identifier">required_positionals</span>.<span class="ruby-identifier">size</span>) <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
          <span class="ruby-identifier">diff</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span>
            <span class="ruby-identifier">method_block</span>.<span class="ruby-identifier">type</span>.<span class="ruby-identifier">required_positionals</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Function</span><span class="ruby-operator">::</span><span class="ruby-constant">Param</span>.<span class="ruby-identifier">new</span>(
              <span class="ruby-value">type:</span> <span class="ruby-identifier">untyped</span>,
              <span class="ruby-value">name:</span> <span class="ruby-keyword">nil</span>
            )
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>

        <span class="ruby-keyword">if</span> <span class="ruby-identifier">keywords</span>
          <span class="ruby-identifier">keywords</span>.<span class="ruby-identifier">children</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each_slice</span>(<span class="ruby-value">2</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key_node</span>, <span class="ruby-identifier">value_node</span><span class="ruby-operator">|</span>
            <span class="ruby-keyword">if</span> <span class="ruby-identifier">key_node</span>
              <span class="ruby-identifier">key</span> = <span class="ruby-identifier">key_node</span>.<span class="ruby-identifier">children</span>[<span class="ruby-value">0</span>]
              <span class="ruby-identifier">method_block</span>.<span class="ruby-identifier">type</span>.<span class="ruby-identifier">required_keywords</span>[<span class="ruby-identifier">key</span>] <span class="ruby-operator">||=</span>
                <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Function</span><span class="ruby-operator">::</span><span class="ruby-constant">Param</span>.<span class="ruby-identifier">new</span>(
                  <span class="ruby-value">type:</span> <span class="ruby-identifier">untyped</span>,
                  <span class="ruby-value">name:</span> <span class="ruby-keyword">nil</span>
                )
            <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">method_block</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-each_child" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">each_child</span><span
                                class="method-args">(node, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="each_child-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/prototype/helpers.rb, line 85</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each_child</span>(<span class="ruby-identifier">node</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">each_node</span> <span class="ruby-identifier">node</span>.<span class="ruby-identifier">children</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-each_node" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">each_node</span><span
                                class="method-args">(nodes) { |child| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="each_node-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/prototype/helpers.rb, line 89</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each_node</span>(<span class="ruby-identifier">nodes</span>)
  <span class="ruby-identifier">nodes</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">RubyVM</span><span class="ruby-operator">::</span><span class="ruby-constant">AbstractSyntaxTree</span><span class="ruby-operator">::</span><span class="ruby-constant">Node</span>)
      <span class="ruby-keyword">yield</span> <span class="ruby-identifier">child</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-keyword_hash-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">keyword_hash?</span><span
                                class="method-args">(node)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="keyword_hash-3F-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/prototype/helpers.rb, line 109</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">keyword_hash?</span>(<span class="ruby-identifier">node</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">node</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">node</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:HASH</span>
    <span class="ruby-identifier">node</span>.<span class="ruby-identifier">children</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">children</span>.<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">each_slice</span>(<span class="ruby-value">2</span>).<span class="ruby-identifier">all?</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">_</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">key</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:LIT</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">children</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>)
    }
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">false</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-untyped" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">untyped</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="untyped-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/prototype/helpers.rb, line 125</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">untyped</span>
  <span class="ruby-ivar">@untyped</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Bases</span><span class="ruby-operator">::</span><span class="ruby-constant">Any</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">location:</span> <span class="ruby-keyword">nil</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

